<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
</head>
<body>
<div class="x-body">
    <form class="layui-form">

        <div class="layui-form-item">
            <label for="userName" class="layui-form-label">
                <span class="x-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="userName" name="userName"  required="" lay-verify="required"
                       autocomplete="off" class="layui-input" placeholder="姓名">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="userUsername" class="layui-form-label">
                <span class="x-red">*</span>用户名
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="userUsername" name="userUsername" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" placeholder="用户名">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="userPasswd" class="layui-form-label">
                <span class="x-red">*</span>密码
            </label>
            <div class="layui-input-inline">
                <input type="password"  id="userPasswd" name="userPasswd" minlength="6" required="" lay-verify="staffPwd"
                       autocomplete="off" class="layui-input" placeholder="密码">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="userIdenty" class="layui-form-label">
                <span class="x-red">*</span>身份证号
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="userIdenty" name="userIdenty" maxlength="18" oninput = "value=value.replace(/[^\d]/g,'')" onblur="limitIdent(this.value)" required=""
                       lay-verify="identity" autocomplete="off" class="layui-input" placeholder="身份证号,12345678910111213x">
            </div>
        </div>

       <div class="layui-form-item">
            <label for="userBirth" class="layui-form-label">
                <span class="x-red">*</span>生日
            </label>
            <div class="layui-input-inline">
                <!--<input type="text"  id="userBirth" name="userBirth" class="layui-input" placeholder="生日" required="">-->
                <input type="date"  id="userBirth" name="userBirth" required="" lay-verify="required">
            </div>
        </div>



        <div class="layui-form-item">
            <label for="userTel" class="layui-form-label">
                <span class="x-red">*</span>电话
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="userTel"name="userTel" maxlength="11" onblur="limitPhone(this.value)" oninput = "value=value.replace(/[^\d]/g,'')"
                       required="" lay-verify="phone" autocomplete="off" class="layui-input" placeholder="电话">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="userAddr" class="layui-form-label">
                <span class="x-red">*</span>地址
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="userAddr" name="userAddr" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" placeholder="xx省xx市">
            </div>
        </div>

        <div class="layui-form-item">
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
</body>
</html>
<script>
    //form表单,layer弹出框
    layui.use(['form','layer'],function () {
        $ = layui.jquery;
        var form = layui.form, layer = layui.layer;

        //新增按钮
        form.on('submit(add)', function (data) {

            $.ajax({
                url: "/user/submitAdd",
                async: false,
                type: "POST",
                dataType: "json",
                data: data.field,
                success:function (data) {
                    //提示信息
                    layer.alert(data.info);
                    //放入了map中，调用info
                    if (data.info=="新增会员成功"){
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        //刷新
                        parent.window.location.replace("/user/list")
                    }
                }

            })
            return false;
        });
    })
</script>